import {
  ChangeDetectionStrategy, ChangeDetectorRef,
  Component,
  ContentChild, Host, Input, Optional,
  TemplateRef, ViewEncapsulation,
} from '@angular/core';
import { ApesNoAnimationDirective, isNotNil, zoomBigMotion } from '@shared/apes/core';
import { ApesTSType } from "@shared/apes/core/types/template";
import { ApesToolTipBaseComponent, ApesToolTipBaseComponentLegacy, ApesToolTipComponent } from '@shared/apes/tooltip';


@Component({
  selector           : 'apes-popover',
  exportAs           : 'apesPopoverComponent',
  animations         : [ zoomBigMotion ],
  templateUrl        : './apes-popover.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
  encapsulation: ViewEncapsulation.None,
  preserveWhitespaces: false,
  providers: [
    {
      provide: ApesToolTipBaseComponentLegacy,
      useExisting: ApesPopoverComponent
    }
  ],
  styles             : [ `
    .apes-popover {
      position: relative;
    }
  ` ]
})
export class ApesPopoverComponent extends ApesToolTipComponent {
  _prefix = 'apes-popover-placement';

  /**
   * Use `neverUsedTemplate` to force `nzTemplate` to be catched by `nzPopoverContent`.
   */
  @Input() @ContentChild('neverUsedTemplate', { static: true }) apesTitle: ApesTSType;
  @Input() @ContentChild('apesTemplate', { static: true }) apesContent: ApesTSType;

  constructor(cdr: ChangeDetectorRef, @Host() @Optional() public noAnimation?: ApesNoAnimationDirective) {
    super(cdr, noAnimation);
  }
}
